
KERNELDIR := ../linux-2.6.28
MODDIR := /lib/modules/$(KERNELVERSION)/kernel/net/netfilter/

CC = gcc

IPTABLES_SRC = ../../iptables/iptables-1.4.4
IPTABLES_INCLUDE = -I$(IPTABLES_SRC)/include
IPTABLES_VERSION = $(shell cat $(IPTABLES_SRC)/Makefile | grep -e '^IPTABLES_VERSION:=' | cut -d"=" -f2)
IPTABLES_OPTION = -DIPTABLES_VERSION=\"$(IPTABLES_VERSION)\"

ifneq ($(KERNELRELEASE),)
obj-m := ipt_ipmac.o
else
all: ipt_ipmac ipmaccfg 

ipt_ipmac: ipt_ipmac.c ipt_ipmac.h
	$(MAKE) -C $(KERNELDIR) M=`pwd` modules

ipmaccfg: ipmacconf.c
	$(CC) -o ipmaccfg ipmacconf.c
endif

libipt_ipmac.so:libipt_ipmac.c 
	$(CC) $(CFLAGS) $(IPTABLES_OPTION) $(IPTABLES_INCLUDE) -fPIC -c libipt_ipmac.c
	ld -shared -o libipt_ipmac.so libipt_ipmac.o

install:ipt_ipmac ipmaccfg
	@[ -d $(DESTDIR)$(MODDIR) ] || mkdir -p $(DESTDIR)$(MODDIR)
	cp -f *.ko $(DESTDIR)$(MODDIR)

clean:
	rm -rf *.o *~ .depend *.ko* *.mod.c .tmp_versions Module.symvers .*cmd modules.order ipmaccfg
